<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
	<script src="ajax.js" charset="utf-8"></script>
	<script type="text/javascript">
		window.onload=function(){
			var oTxtUser=document.getElementById('user');
			var oTxtPass=document.getElementById('pass');
			var oBtnReg=document.getElementById('reg_btn');
			var oBtnLogin=document.getElementById('log_btn');

         oBtnReg.onclick=function(){
         	ajax({
         		url:'/user',
         		data:{act:'reg',user:oTxtUser.value,pass:oTxtPass.value},
         		type:'get',
         		success:function(str){
         			var json=eval('{'+str+'}');
                     
                   if(json.ok){
                   	alert('注册成功');
                   }else{
                   	alert('注册失败：'+json.msg)
                   }
         		},
         		error:function(){
                    alert("通信错误");
         		}

         	});
         };


		}
	</script>
</head>
<body>
	用户： <input type="text" id="user" ><br/>
	    密码:  <input type="password" id="pass"><br/>
	    <input type="button" value="注册" id="reg_btn">
	     <input type="button" value="登录" id="log_btn">
</body>
</html>